﻿using System;

namespace TextEditor
{
    

    public class A_SetSub : A_Action
    {
        public override string ActionName()
        {
            return "sub";
        }

        public override int CheckState()
        {
            ZYTextChar currentElement = base.myOwnerDocument.Content.GetPreChar();            
            if (currentElement != null)
            {
                return (currentElement.Sub ? 1 : 0);
            }
            return -1;
        }

        public override A_Action Clone()
        {
            A_SetSub sub = new A_SetSub();
            sub.BaseCloneFrom(this);
            return sub;
        }

        public override bool Execute()
        {
            base.myOwnerDocument.SetSelectionSub(base.Param1 == "1");
            return true;
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.CanModify();
        }

        public override bool UIExecute()
        {
            base.myOwnerDocument.SetSelectionSub(this.CheckState() == 0);
            return true;
        }
    }
}

